/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.ucase.casemain.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseOfflineDocumentRecordSaveDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.model.CaseOfflineDocumentQueryDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.service.ICaseOfflineDocumentRecordService;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.CaseOfflineDocumentDetailVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 描述: 案件线下文书记录表 case_offline_document_record 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年07月26日
 */
@RestController
@RequestMapping("/punish/ucase/offline/document")
public class CaseOfflineDocumentRecordController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseOfflineDocumentRecordController.class);

    @Resource
    private ICaseOfflineDocumentRecordService caseOfflineDocumentRecordService;

    /**
     * 【V1.3.2】描述：保存线下上传文书
     *
     * @return {@link Result }
     * @author shishengyao
     * @date 2022/07/26
     */
    @PostMapping("/saveCaseOfflineDocument")
    @ApiOperation(value = "描述：保存线下上传文书", httpMethod = "POST")
    public Result saveCaseOfflineDocument(@RequestBody @Validated CaseOfflineDocumentRecordSaveDto saveDto) {
        int count = caseOfflineDocumentRecordService.saveCaseOfflineDocument(saveDto);
        if (count > 0) {
            return Result.success(Constant.STRING_SAVE_SUCCESS);
        }
        return Result.error(Constant.STRING_SAVE_FAIL);
    }

    /**
     * 【V1.3.2】描述：获取线下上传文书详情
     *
     * @return {@link Result }
     * @author shishengyao
     * @date 2022/07/26
     */
    @PostMapping("/getCaseOfflineDocument")
    @ApiOperation(value = "描述：获取线下上传文书详情", httpMethod = "POST")
    public Result<CaseOfflineDocumentDetailVo> getCaseOfflineDocument(@RequestBody @Validated CaseOfflineDocumentQueryDto queryDto) {
        CaseOfflineDocumentDetailVo caseOfflineDocumentDetail = caseOfflineDocumentRecordService.getCaseOfflineDocumentDetail(queryDto);
        return Result.success("查询成功", caseOfflineDocumentDetail);
    }

    /**
     * 【V1.4.1】描述：删除线下上传文书
     *
     * @return {@link Result }
     * @author zhangqiang
     * @date 2022/08/24
     */
    @PostMapping("/deleteCaseOfflineDocument")
    @ApiOperation(value = "描述：删除线下上传文书", httpMethod = "POST")
    public Result deleteCaseOfflineDocument(@RequestBody @Validated CaseOfflineDocumentQueryDto queryDto) {
        int count = caseOfflineDocumentRecordService.deleteCaseOfflineDocument(queryDto);
        if (count > 0) {
            return Result.success(Constant.STRING_OPERATE_SUCCESS);
        }
        return Result.error(Constant.STRING_OPERATE_FAIL);
    }
}
